package com.etc.controller;

import com.etc.entity.Discuss;
import com.etc.entity.DiscussExt;
import com.etc.service.DiscussService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.HashMap;
import java.util.Map;

/**
 * 评论的Controller
 * @author Administrator
 *
 */
@Controller
public class DiscussController {
	
	@Autowired
	private DiscussService discussService;
	
	@RequestMapping("findDiscussList")
	@ResponseBody
	public DiscussExt findDiscussList(@RequestParam(required=true) Integer uid) {
		DiscussExt discussExt = new DiscussExt();
		discussExt.setComments(discussService.findDiscussList(uid));
		discussExt.setStatus(1);
		return discussExt;
	}
	
	@RequestMapping("insertDiscuss")
	@ResponseBody
	public Map<String, Object> insertDiscuss(Discuss discuss) {
		//插入评论
		discussService.insertDiscuss(discuss);
		Map<String, Object> myMap = new HashMap<>();
		myMap.put("ret", 0);
		myMap.put("msg", "评论提交成功!");
		return myMap;
	}
	
}
